package time;

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JComboBox;
import time.Reminder.RemindTask;

public class TimeDemo {

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TimeDemo window = new TimeDemo();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public TimeDemo() {
		initialize();
	}

	String[] arr = { "爷爷" };
	JComboBox comboBox = new JComboBox(arr);
	public void getArr(Timer t) {
		String[] temp = { "舅舅", "阿姨", "姥姥", "姥爷" };
		arr = temp;
		System.out.println("getArr");
	    
	}

	// ************************************
	Timer timer;
	public void begin() {
		timer = new Timer();
		timer.schedule(new RemindTask(), 3 * 1000);
	}
	class RemindTask extends TimerTask {
		public void run() {
			System.out.println("3秒后开始**********************了");// do something
			String[] temp = { "舅舅", "阿姨", "姥姥", "姥爷" };
			comboBox.removeAllItems();
			for (int i = 0; i < temp.length; i++) {
				comboBox.addItem(temp[i]);
			}
			comboBox.setSelectedIndex(0);
			timer.cancel();
		}
	}
	// *******************************************************

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(
				new FlowLayout(FlowLayout.CENTER, 5, 5));
		 
		begin();
		
		comboBox.setMaximumRowCount(8);
		frame.getContentPane().add(comboBox);

	}

}
